#include <QGuiApplication>
#include <QQmlApplicationEngine>

#include <QQmlContext>

#include "device_controller_ui.h"

#include <QQuickStyle>

int main(int argc, char *argv[])
{
    QQuickStyle::setStyle("Fusion");

    QGuiApplication app(argc, argv);
    QQmlApplicationEngine engine;
    engine.addImportPath("D://MyWorkLog/MainLine2/Qt6/CustomControls");
    engine.rootContext()->setContextProperty("control", new DeviceControllerUI());
    const QUrl url(u"qrc:/SerialPortEngine/Main.qml"_qs);
    QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
        &app, [url](QObject *obj, const QUrl &objUrl) {
            if (!obj && url == objUrl)
                QCoreApplication::exit(-1);
        }, Qt::QueuedConnection);
    engine.load(url);

    return app.exec();
}
